double mysqrt(double y) {
    if (y < 1e-9) {
        return 0.0;
    }
    
    double low, high;
    if (y >= 1.0) {
        low = 1.0;
        high = y;
    } else {
        low = y;
        high = 1.0;
    }
    
    double mid;
    do {
        mid = (low + high) / 2;
        double mid_sq = mid * mid;
        
        if (mid_sq < y) {
            low = mid;
        } else {
            high = mid;
        }
    } while (fabs(mid * mid - y) >= 0.001);
    
    return mid;
}